from sqlalchemy.ext.asyncio import AsyncSession

from dc_shop.database import repositories as repo
from dc_shop.database.uow.base import SQLAlchemyBaseUoW


class SQLAlchemyUoW(SQLAlchemyBaseUoW):
    def __init__(
        self,
        *,
        session: AsyncSession,
        user_repo: repo.UserRepoImpl,
        order_repo: repo.OrderRepoImpl,
        delivery_zone_repo: repo.DeliveryZoneRepoImpl,
        product_repo: repo.ProductRepoImpl,
        cart_repo: repo.CartRepoImpl,
        cart_reader: repo.CartReaderImpl,
        payment_method_repo: repo.PaymentMethodRepoImpl,
        shop_repo: repo.ShopRepoImpl,
        ticket_repo: repo.TicketRepoImpl,
        stats_repo: repo.StatsRepoImpl,
        review_repo: repo.ReviewRepoImpl,
        discount_repo: repo.DiscountRepoImpl,
        promocode_repo: repo.PromocodeRepoImpl,
        bot_settings_reader: repo.BotSettingsReaderImpl,
        bot_settings_repo: repo.BotSettingsRepoImpl,
    ) -> None:
        self.user_repo = user_repo
        self.order_repo = order_repo
        self.delivery_zone_repo = delivery_zone_repo
        self.product_repo = product_repo
        self.cart_repo = cart_repo
        self.cart_reader = cart_reader
        self.payment_method_repo = payment_method_repo
        self.shop_repo = shop_repo
        self.ticket_repo = ticket_repo
        self.stats_repo = stats_repo
        self.review_repo = review_repo
        self.discount_repo = discount_repo
        self.promocode_repo = promocode_repo
        self.bot_settings_reader = bot_settings_reader
        self.bot_settings_repo = bot_settings_repo

        super().__init__(session=session)


def build_uow(session: AsyncSession):
    return SQLAlchemyUoW(
        session=session,
        user_repo=repo.UserRepoImpl(session),
        order_repo=repo.OrderRepoImpl(session),
        delivery_zone_repo=repo.DeliveryZoneRepoImpl(session),
        product_repo=repo.ProductRepoImpl(session),
        cart_repo=repo.CartRepoImpl(session),
        cart_reader=repo.CartReaderImpl(session),
        payment_method_repo=repo.PaymentMethodRepoImpl(session),
        shop_repo=repo.ShopRepoImpl(session),
        ticket_repo=repo.TicketRepoImpl(session),
        stats_repo=repo.StatsRepoImpl(session),
        review_repo=repo.ReviewRepoImpl(session),
        discount_repo=repo.DiscountRepoImpl(session),
        promocode_repo=repo.PromocodeRepoImpl(session),
        bot_settings_reader=repo.BotSettingsReaderImpl(session),
        bot_settings_repo=repo.BotSettingsRepoImpl(session),
    )
